﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utilities
{
    public static class Validator
    {
        // returner true hvis det er en valid string, ellers false
        public static bool IsValidString(this string str)
        {
            return (!String.IsNullOrEmpty(str) || !String.IsNullOrWhiteSpace(str));
        }

        public static bool IsValidStringAndHasMaxLengthOf(this string str, int length)
        {
            if (String.IsNullOrEmpty(str) || String.IsNullOrWhiteSpace(str))
            {
                return false;
            }

            return str.Count() <= length;
        }

        public static bool IsMaxLength(this string str, int length)
        {
            return str.Count() <= length;
        }

        public static bool IsIntegerGreaterThanZero(this string str)
        {
            int tmp = 0;
            int.TryParse(str, out tmp);

            return tmp > 0;
        }

    }
}
